def f(bj, lv, year, bc):
    b_bj = bj
    for i in range(year):
        print(bj*lv)
        bj = bj * (1 + lv)+bc

    print("b_bj:{}".format(bc*year+b_bj))
    print("lr:{}".format(bj-b_bj-year*bc))
    return bj

# a = f(300000, 0.01, 200, 0)
# print(a)


def f2(level, count, base):
    power = 0
    result = 1
    while power < count:
        result *= level
        power += 1
        print("result: ---")
        print(result)
    return result

b = f2(1.04, 20, 1)
print(b)

def f3(bj, n):
    for i in range(n):
        bj = bj * 0.9
        print(bj)

# f3(10000, 10)
# print(30*365/0.0435)


def f4(total_amount, years, interest_rate):
    principal = 0
    for i in range(years*2):  # 外层循环，循环次数为年数的两倍
        for j in range(100):  # 内层循环，循环100次
            total_amount = total_amount+100  # 每次循环增加100
        total_amount = total_amount * (1+interest_rate/2)  # 每半年计算一次利息
        principal = (i+1)*100*100  # 计算累计投入的本金
        print("year:{} total_amount:{} principal:{} interest:{}".format(i, total_amount, principal, total_amount-principal))  # 输出当前年份、总金额、累计本金和利息

# f4(100, 20, 0.045)